package com.abvnet.project.water.project.service;

import com.abvnet.common.utils.security.ShiroUtils;
import com.abvnet.common.utils.text.Convert;
import com.abvnet.project.water.project.domain.ProjectContract;
import com.abvnet.project.water.project.mapper.ProjectContractMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 项目合同 服务层实现
 * 
 * @author duj
 * @date 2019-08-15
 */
@Service
public class ProjectContractServiceImpl implements IProjectContractService {
	@Autowired
	private ProjectContractMapper projectContractMapper;

    @Override
    public ProjectContract selectProjectContractByProjectId(Long projectId) {
        return projectContractMapper.selectProjectContractByProjectId(projectId);
    }

    /**
     * 查询项目合同信息
     * 
     * @param contractId 项目合同ID
     * @return 项目合同信息
     */
    @Override
	public ProjectContract selectProjectContractById(Long contractId) {
	    return projectContractMapper.selectProjectContractById(contractId);
	}
	
	/**
     * 查询项目合同列表
     * 
     * @param projectContract 项目合同信息
     * @return 项目合同集合
     */
	@Override
	public List<ProjectContract> selectProjectContractList(ProjectContract projectContract) {
	    return projectContractMapper.selectProjectContractList(projectContract);
	}
	
    /**
     * 新增项目合同
     * 
     * @param projectContract 项目合同信息
     * @return 结果
     */
	@Override
	public int insertProjectContract(ProjectContract projectContract) {
        projectContract.setCreateBy(ShiroUtils.getLoginName());
        projectContract.setUserId(ShiroUtils.getUserId());
        projectContract.setUserName(ShiroUtils.getSysUser().getUserName());
	    return projectContractMapper.insertProjectContract(projectContract);
	}
	
	/**
     * 修改项目合同
     * 
     * @param projectContract 项目合同信息
     * @return 结果
     */
	@Override
	public int updateProjectContract(ProjectContract projectContract) {
	    return projectContractMapper.updateProjectContract(projectContract);
	}

	/**
     * 删除项目合同对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteProjectContractByIds(String ids) {
		return projectContractMapper.deleteProjectContractByIds(Convert.toStrArray(ids));
	}
	
}